package org.hao.samples.dao;

import java.util.List;

import org.hao.samples.model.Subject;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public class SubjectHibernateDAO extends BaseHibernateDAO<Subject> implements ISubjectDAO {

	@Override
	public List<Subject> findAllsubject() {
		String hql = "FROM Subject";
		return this.find(hql);
	}

	@Override
	public void createsubject(Subject subject) throws Exception {
		this.save(subject);
	}

	@Override
	public Subject getsubjectById(Integer id) {
		return this.get(id);
	}

	@Override
	public void editsubject(Subject subject) throws Exception {
		this.update(subject);
	}

	@Override
	public void deletesubject(Integer id) throws Exception {
		Subject subject = this.get(id);
		if (subject != null) {
			this.delete(subject);
		}
	}



}
